package com.itheima.dao;

import com.itheima.model.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface IUserDao {
    @Select("select*from users")
    List<User> findAll();
    @Select("select*from users where id=#{id}")
    User findOneById(@Param("id") Integer id);
    @Select("select*from users where name=#{name}")
    List<User> findByName(@Param("name") String name);
    @Insert("insert into users values(null,#{name},#{sex})")
    int save (@Param("name") String name,@Param("sex") String sex);
    @Insert("insert into users values(null,#{user.name},#{user.sex})")
    int save2(@Param("user") User user);

    @Update("update users  set name=#{name},sex=#{sex}  where id=#{id}")
    int update(@Param("name") String name,@Param("sex") String sex,@Param("id") Integer id);
    @Delete("dalete from users where id=#{id}")
    int delete (@Param("id") Integer id);
}
